package exercises.leetcode;

import java.util.Scanner;

/**
 * <a href="">
 * </a>
 *
 * <p><span color="#87CEEB">描述:</span>
 *
 * @author or2
 * @date 2021年10月23日 时间: 14:40
 */
public class Saike_00_4 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int bounds = scanner.nextInt();
        final int MOD = scanner.nextInt();
        int s0 = 1, s1 = 2,
                a0 = 1, a1 = 2;
        int sum = 3;
        for (int i = 3; i < bounds; i++) {
            int s2 = s0 + s1;
            int a2 = s0 * a0 + s1 * a1;
            System.out.print(a2 + "\t");
            sum += a2;
            sum %= MOD;
            System.out.println(sum);
            s0 = s1;
            s1 = s2;
        }
    }
}
